﻿namespace SmartSoft.Controls.ChildGridControls
{
    using SmartSoft.Properties;
    using System;
    using System.ComponentModel;
    using System.Windows.Forms;

    public class StatusCell : DataGridViewImageCell
    {
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            object cANCELED = null;
            if (value != null)
            {
                if ((base.DataGridView.Columns[base.ColumnIndex] as StatusColumn).StatusField == 0)
                {
                    if ((bool) value)
                    {
                        return Resources.LOCK;
                    }
                    return Resources.UNLOCK;
                }
                if ((base.DataGridView.Columns[base.ColumnIndex] as StatusColumn).StatusField != 1)
                {
                    return cANCELED;
                }
                if (((int) value) == 0)
                {
                    return Resources.UNPOSTED;
                }
                if (((int) value) == 1)
                {
                    return Resources.POSTED;
                }
                if (((int) value) == 2)
                {
                    cANCELED = Resources.CANCELED;
                }
            }
            return cANCELED;
        }
    }
}

